package sugarbind_input


class Binding {
	

	String binding_Notes	
//	Integer article_Import_Ref 
	
	
    static constraints = {

		database(nullable:false)
		ligand(nullable:false)
//		articles(nullable:false)
//		strain(nullable:true)
		binding_Strength(nullable:true)
		lectin(nullable:false)
		//fimbria(nullable:true)
//		methods(nullable:true)
		binding_Notes(nullable:true)
//		article_Import_Ref(nullable:false)
		
		//UNIQUE CONSTRAINT
//		ligand(unique:['binding_Notes','database','lectin'])
    }
	
	static hasMany = [articles:Article, methods: Method]
	static hasOne = [database:Database, ligand:Ligand, lectin: Lectin, binding_Strength: Binding_Strength]
	
	
	static mapping = {
//		id column: 'binding_id'
		id generator: 'sequence', params: [sequence: 'binding_id_seq']

		methods joinTable: [name: "binding_method", key: 'binding_id']
		articles joinTable: [name: "binding_article", key: 'binding_id']
	}
	
	public String toString(){
		String lec = "Unknown lectin"
		String strains = ""
//		for(bsa in binding_Strain_Articles)
//		{
//			strains += bsa.strain.strain_Name
//		}
		if(lectin!=null){lec = lectin.lectin_Name}
//		if(lectin!=null){lec = lectin.lectin_Name}
		id + "-" + database.database_Name;// + " : " +  ligand.structure.iupac  + " / "+ lec //+ " / "// + binding_Strain_Articles.strain.strain_Name//+ binding_Strain_Articles.strain.strain_Name
	}
}
